package hui.zhang.web.action.system;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.apache.poi.ss.formula.functions.T;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.alibaba.fastjson.JSON;
import com.opensymphony.xwork2.ActionSupport;

import hui.zhang.utils.BaseAction;

@ParentPackage("struts-default")
@Namespace("/")
@Controller
@Scope("prototype")
public class LoginAction extends ActionSupport {
	
	@Action(value="system_ip")
	public String getIP() throws IOException {
		HttpServletRequest request = ServletActionContext.getRequest();
		String ip = null;
		if (request.getHeader("x-forwarded-for") == null) {
			 ip = request.getRemoteAddr();
		} else {
			ip = request.getHeader("x-forwarded-for");
		}
		String jsonString = JSON.toJSONString(ip);
		ServletActionContext.getResponse().getWriter().write(jsonString);
		return NONE;
	}

}
